<?php
namespace app\model\front;

use think\Db;

class Article
{
    //获取所有文章
    public function get_article_all($where,$sort='')
    {
        $result_lists = Db::name('article')->where($where)->order($sort)->select();
        return $result_lists;
    }
    //获取文章列表
    public function get_article_lists($where,$sort='',$paginate=10)
    {
        $result_lists = Db::name('article')->where($where)->order($sort)->paginate($paginate);
        return $result_lists;
    }

    //获取指定条数文章
    public function get_article_limit($where,$sort='',$limit=10){
        $result_lists = Db::name('article') ->field('id,title,seo_name_en,add_time,image,describe,column_name')->where($where)->order($sort)->limit($limit)->select();
        return $result_lists;
    }

    //获取文章列表-between条件
    public function get_article_lists_between($where,$between='',$sort='',$paginate=10)
    {
        if(empty($between))return false;
        $result_lists = Db::name('article')->where($where)->where($between['val'],'between','"'.$between['one'].'","'.$between['two'].'"')->order($sort)->paginate($paginate);
        return $result_lists;
    }

    //文章详情
    public function article_detail($name){
        $result = Db::name('article')->where('seo_name_en',$name)->find();
        return $result;
    }

    //文章访问
    public function article_read($name){
        $result =Db::name('article')->where('seo_name_en', $name)->setInc('read_num');
        return $result;
    }




}


